package com.ruoyi.yuan.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yuan.domain.Galaxy;
import com.ruoyi.yuan.service.IGalaxyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 星系信息Controller
 * 
 * @author guifeng
 * @date 2022-08-21
 */
@Api("星系信息")
@RestController
@RequestMapping("/yuan/galaxy")
public class GalaxyController extends BaseController
{
    @Autowired
    private IGalaxyService galaxyService;

    /**
     * 查询星系信息列表
     */
    @ApiOperation("查询星系信息列表")
    @PreAuthorize("@ss.hasPermi('yuan:galaxy:list')")
    @GetMapping("/list")
    public TableDataInfo list(Galaxy galaxy)
    {
        startPage();
        List<Galaxy> list = galaxyService.selectGalaxyList(galaxy);
        return getDataTable(list);
    }

    /**
     * 导出星系信息列表
     */
    @ApiOperation("导出星系信息列表")
    @PreAuthorize("@ss.hasPermi('yuan:galaxy:export')")
    @Log(title = "星系信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Galaxy galaxy)
    {
        List<Galaxy> list = galaxyService.selectGalaxyList(galaxy);
        ExcelUtil<Galaxy> util = new ExcelUtil<Galaxy>(Galaxy.class);
        util.exportExcel(response, list, "星系信息数据");
    }

    /**
     * 获取星系信息详细信息
     */
    @ApiOperation("获取星系信息详细信息")
    @PreAuthorize("@ss.hasPermi('yuan:galaxy:query')")
    @GetMapping(value = "/{galaxyId}")
    public AjaxResult getInfo(@PathVariable("galaxyId") Long galaxyId)
    {
        return AjaxResult.success(galaxyService.selectGalaxyByGalaxyId(galaxyId));
    }

    /**
     * 新增星系信息
     */
    @ApiOperation("新增星系信息")
    @PreAuthorize("@ss.hasPermi('yuan:galaxy:add')")
    @Log(title = "星系信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Galaxy galaxy)
    {
        return toAjax(galaxyService.insertGalaxy(galaxy));
    }

    /**
     * 修改星系信息
     */
    @ApiOperation("修改星系信息")
    @PreAuthorize("@ss.hasPermi('yuan:galaxy:edit')")
    @Log(title = "星系信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Galaxy galaxy)
    {
        return toAjax(galaxyService.updateGalaxy(galaxy));
    }

    /**
     * 删除星系信息
     */
    @ApiOperation("删除星系信息")
    @PreAuthorize("@ss.hasPermi('yuan:galaxy:remove')")
    @Log(title = "星系信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{galaxyIds}")
    public AjaxResult remove(@PathVariable Long[] galaxyIds)
    {
        return toAjax(galaxyService.deleteGalaxyByGalaxyIds(galaxyIds));
    }
}
